package org.itboys.core.controller.web.company;

import org.itboys.admin.tools.AdminSessionHolder;
import org.itboys.core.dto.order.SundayRecycleOrderDto;
import org.itboys.core.dto.order.SundaySendOrderDto;
import org.itboys.core.entity.mongo.SundayMember;
import org.itboys.core.entity.mysql.order.SundayRecycleOrder;
import org.itboys.core.entity.mysql.order.SundayRecycleOrderModel;
import org.itboys.core.entity.mysql.order.SundaySendOrder;
import org.itboys.core.entity.mysql.order.SundaySendOrderModel;
import org.itboys.core.service.mongo.web.SundayMemberService;
import org.itboys.core.service.mysql.web.SundayRecycleOrderService;
import org.itboys.framework.query.JsonPageUtils;
import org.itboys.framework.spring.controller.BaseController;
import org.itboys.param.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 作者：zzq
 * 时间：2018/12/28
 * 描述：
 */
@Controller
@RequestMapping("/sunday/web/company/recycleOrder")
public class SundayCompanyRecycleOrderController extends BaseController {
    @Autowired
    private SundayRecycleOrderService recycleOrderService;
    @Autowired
    private SundayMemberService memberService;

    @RequestMapping("/index")
    public String index(
            HttpServletRequest request,
            Model model
    ) {
        SundayMember member = memberService.getMemberByUserId(AdminSessionHolder.getAdminUserId());
        model.addAttribute("member", member);
        return "/sunday/company/recycleOrder/index";
    }

    @RequestMapping("/input")
    public String input(
            HttpServletRequest request,
            @RequestParam(value = "id", required = true) Long id,
            Model model
    ) {
        SundayRecycleOrder result = recycleOrderService.find(id);
        model.addAttribute("order", result);
        return "/sunday/company/recycleOrder/input";
    }


    /**
     * 分页查询
     *
     * @param request
     * @param response
     */
    @RequestMapping("/select")
    public void select(
            HttpServletRequest request,
            HttpServletResponse response
    ) {
        PageResult<SundayRecycleOrder> result = recycleOrderService.select(request);
        JsonPageUtils.renderJsonPage(result.getTotal(), result.getData(), response);
    }






}
